package studio.raptor.ddal.dashboard.log.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
import studio.raptor.ddal.dashboard.log.bo.SqlProcessLogExtendData;

import java.util.Date;
import java.util.List;

/**
 * Created by dell on 2018/1/4.
 */
@Repository
public interface SqlProcessLogRepository  extends PagingAndSortingRepository<SqlProcessLogExtendData, String>,JpaSpecificationExecutor<SqlProcessLogExtendData> {

//    List<SqlProcessLogExtendData> findByTraceId(String traceId);
//
//    Page<SqlProcessLogExtendData> findBySucess(String sucess, Pageable pageable);
//
//    List<SqlProcessLogExtendData> findAll(Specification<SqlProcessLogExtendData> spec);

    @Query("select dto from SqlProcessLogExtendData dto where acceptTime between ?1 and ?2 and appName=?3")
    public List<SqlProcessLogExtendData> findByAcceptTimeBetweenAndAppName(Date acceptBeginTime,Date acceptEndTime,String appName,Pageable pageable);

    @Query("select dto from SqlProcessLogExtendData dto where acceptTime between ?1 and ?2 and appName=?3 and sqlType=?4")
    public List<SqlProcessLogExtendData> findByAcceptTimeBetweenAndAppNameAndSqlType(Date acceptBeginTime,Date acceptEndTime,String appName,String sqlType, Pageable pageable);

}
